﻿resources = {
    /// <summary>
    /// 合约买卖方向
    /// </summary>
    ContractType:
    {
        Buy: 1,
        Sell: 2
    },

    /// <summary>
    /// 委托状态 已委托/已成交/已撤单
    /// </summary>
    ContractOrderStatus:
    {
        All: 0,
        Ordering: 1,
        Ordered: 2,
        Cancel: 3,
    },

    /// <summary>
    /// 委托类型 市价委托/指价委托
    /// </summary>
    ContractOrderPriceType:
    {
        /// <summary>
        /// 市价委托
        /// </summary>
        MarketPrice: 1,

        /// <summary>
        /// 指价委托
        /// </summary>
        LimitPrice: 2,

        /// <summary>
        /// 止损价格
        /// </summary>
        StopLossPrice: 3,

        /// <summary>
        /// 止盈价格
        /// </summary>
        StopProfitPrice: 4
    },

    /// <summary>
    /// 交易类型 建仓/平仓
    /// </summary>
    ContractPositionType:
    {
        /// <summary>
        /// 开仓
        /// </summary>
        Open: 1,

        /// <summary>
        /// 平仓
        /// </summary>
        Close: 2
    },

    GoodsStatus:
    {
        /// <summary>
        /// 启用
        /// </summary>
        Enabled: 1,

        /// <summary>
        /// 禁用
        /// </summary>
        Disabled: 2
    },

    /// <summary>
    /// 资金风险级别
    /// </summary>
    MoneyRiskLevel:
    {
        /// <summary>
        /// 正常
        /// </summary>
        Normal: 0,
        /// <summary>
        /// 无法建仓
        /// </summary>
        NonOpenPosition: 1,
        /// <summary>
        /// 追加保证金
        /// </summary>
        AddAvailableMoney: 2,
        /// <summary>
        /// 强制平仓
        /// </summary>
        ClosePosition: 3
    },

    /// <summary>
    /// 会员状态
    /// </summary>
    MemberStatus:
    {
        /// <summary>
        /// 未激活
        /// </summary>
        Nonactivated: 0,

        /// <summary>
        /// 正常
        /// </summary>
        Normal: 1,

        /// <summary>
        /// 锁定登录
        /// </summary>
        LockedLogin: 2,

        /// <summary>
        /// 锁定资金操作
        /// </summary>
        LockedAsset: 3
    },

    /// <summary>
    /// 合约手续费收取类型
    /// </summary>
    ContractFeeType:
    {
        /// <summary>
        /// 双边收取
        /// </summary>
        Double: 0,
        /// <summary>
        /// 单边建仓收取
        /// </summary>
        Single: 1,
        /// <summary>
        /// 日内平今仓免收
        /// </summary>
        Today: 2
    },

    /// <summary>
    /// 合约手续费数字类型
    /// </summary>
    ContractFeeNumberType:
    {
        /// <summary>
        /// 百分比
        /// </summary>
        Percent: 0,
        /// <summary>
        /// 按手固体数字
        /// </summary>
        Integer: 1
    },

    /// <summary>
    /// 合约手续费收取类型
    /// </summary>
    ContractFeeType:
    {
        /// <summary>
        /// 双边收取
        /// </summary>
        Double: 0,
        /// <summary>
        /// 单边建仓收取
        /// </summary>
        Single: 1,
        /// <summary>
        /// 日内平今仓免收
        /// </summary>
        Today: 2
    },

    GetMoneyColor: function (money) {
        return money > 0 ? "up" : "dn";
    },

    /// <summary>
    /// 获得合约类型颜色
    /// </summary>
    /// <param name="type"></param>
    /// <returns></returns>
    GetContractTypeColor: function (type) {
        return type == this.ContractType.Buy ? "up" : "dn";
    },

    /// <summary>
    /// 获得合约类型
    /// </summary>
    /// <param name="type"></param>
    /// <returns></returns>
    GetContractWay: function (type) {
        switch (type) {
            case this.ContractType.Buy:
                return R("BuyWay", "买入");
            case this.ContractType.Sell:
                return R("SellWay", "卖出");
            default:
                return "";
        }
    },

    /// <summary>
    /// 获得合约类型
    /// </summary>
    /// <param name="type"></param>
    /// <returns></returns>
    GetContractType: function (type) {
        switch (type) {
            case this.ContractType.Buy:
                return R("BuyList", "买&nbsp;&nbsp;&nbsp;&nbsp;");
            case this.ContractType.Sell:
                return R("SellList", "&nbsp;&nbsp;&nbsp;&nbsp;卖");
            default:
                return "";
        }
    },

    /// <summary>
    /// 获得委托状态名称
    /// </summary>
    /// <param name="status"></param>
    /// <returns></returns>
    GetStatusName: function (status) {
        switch (status) {
            case this.ContractOrderStatus.Ordering:
                return '<span class="label label-primary">' + R("OrderStatusOrdering", "成交中") + '</span>';
            case this.ContractOrderStatus.Ordered:
                return '<span class="label label-success">'+R("OrderStatusOrdered", "已成交")+'</span>';
            case this.ContractOrderStatus.Cancel:
                return '<span class="label label-default">' + R("OrderStatusCancel", "已撤单") + '</span>';
            default:
                return "";
        }
    },

    /// <summary>
    /// 获得委托价格类型
    /// </summary>
    /// <param name="type"></param>
    /// <returns></returns>
    GetOrderPriceType: function (type) {
        switch (type) {
            case this.ContractOrderPriceType.MarketPrice:
                return R("MarketPrice", "市价单");
            case this.ContractOrderPriceType.LimitPrice:
                return R("LimitPrice", "指价单");
            case this.ContractOrderPriceType.StopLossPrice:
                return R("StopLossPrice", "止损单");
            case this.ContractOrderPriceType.StopProfitPrice:
                return R("StopProfitPrice", "止盈单");
            default:
                return "";
        }
    },

    /// <summary>
    /// 获得委托仓位类型
    /// </summary>
    /// <param name="type"></param>
    /// <returns></returns>
    GetPositionType: function (type) {
        switch (type) {
            case this.ContractPositionType.Open:
                return '<span class="label label-success">' + R("OpenPosition", "建仓") + '</span>';
            case this.ContractPositionType.Close:
                return '<span class="label label-danger">' + R("ClosePosition", "平仓") + '</span>';
            default:
                return "";
        }
    },

    ///获得手续费收取方式
    GetFeeType: function (type) {
        switch (type) {
            case this.ContractFeeType.Double:
                return R("ContractFeeType.Double", "双边建平");
            case this.ContractFeeType.Single:
                return R("ContractFeeType.Single", "单边");
            case this.ContractFeeType.Today:
                return R("ContractFeeType.Today", "平今免");
            default:
                return "";
        }
    },

    GetGoodsStatus: function (status) {
        switch (status) {
            case this.GoodsStatus.Enabled:
                return R("GoodsStatus.Enabled", "上市");
            case this.GoodsStatus.Disabled:
                return R("GoodsStatus.Disabled", "下市");
        }
    }
}